package com.wn.controller;

import com.wn.entity.Student;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("post")
public class PostController {
    private  final  static  Logger logger = LoggerFactory.getLogger(PostController.class);

    @PostMapping("/test2")
    public String test(Student student){
        logger.debug("name{},age{}",student.getName(),student.getId());
        System.out.println(student);
        return "test2";
    }

    @GetMapping("/test1")
    public String test1( ){
        return "test1";
    }
    @RequestMapping("/deleteUsers")
    public String deleteUsers(int[] ids){
        ModelAndView modelAndView = new ModelAndView();
        List<Integer> list = new ArrayList<>();
        for (int id : ids) {
            list.add(id);
        }
        //放入list 方便前端显示
        modelAndView.addObject("ids", "传入的数组是："+list);
        modelAndView.setViewName("arrayview");
        for (int id : ids) {
            System.out.println(id);
        }
        return "test2";
    }
}
